package com.grace.mapper;

import com.grace.entity.Product;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Repository
public interface ProductMapper {

    /**
     * 查找所有商品
     */
    @Select("select * from product")
    List<Product> findAll();

    /**
     * 新增商品
     */
    @Insert("insert into product (productNum,productName,cityName,departureTime,productPrice,productDesc,productStatus)" +
            " values(#{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus})")
    void save(Product product);

    /**
     * 根据id查找商品
     */
    @Select("select * from product where id=#{id}")
    Product findProductById(String id);


}
